﻿<DataListSpec 
	xmlns="bb_appfx_datalist"
	xmlns:common="bb_appfx_commontypes" 
	ID="2dad806b-fee3-42eb-8a43-7d1b0af52678" 
	Name="EmailsUpdatedSince Data List"
  Description="Get Emails Changed or Inserted After a Specific Date/Time"
  Author="Blackbaud Professional Services"
  common:SecurityUIFolder="Address">



    <!-- define the SP that returns the data for the datalist -->
    <SPDataList SPName="USP_DATALIST_EMAILSCHANGEDSINCE">
      <common:CreateProcedureSQL>
        <![CDATA[
create procedure dbo.USP_DATALIST_EMAILSCHANGEDSINCE(
  @UPDATEDSINCE datetime)
as
	set nocount on;
  
SELECT
  ea.ID,
	ea.CONSTITUENTID,
  ea.EMAILADDRESS,
	eat.DESCRIPTION  as EMAILADDRESSTYPE,
  ea.ISPRIMARY,
  ca.USERNAME as CHANGEDBYUSERNAME
  
FROM EMAILADDRESS ea
	LEFT OUTER JOIN EMAILADDRESSTYPECODE  eat ON ea.EMAILADDRESSTYPECODEID  = eat.ID
  LEFT OUTER JOIN CHANGEAGENT           ca  ON ca.ID                      = ea.CHANGEDBYID



WHERE ea.DATECHANGED >= @UPDATEDSINCE
  
  
			]]>
      </common:CreateProcedureSQL>
    </SPDataList>


    <!-- describe any parameters (other than the context ID) defined on the SP -->
    <Parameters>
      <common:FormMetaData>
        <common:FormFields>
          <common:FormField FieldID="UPDATEDSINCE" Caption="Updated Since" DataType="Date"/>
        </common:FormFields>
      </common:FormMetaData>
    </Parameters>

    <!-- define the output fields in the list -->
    <Output>
      <OutputFields>
        <!-- 0 -->
        <OutputField FieldID="ID" Caption="ID" DataType="Guid" IsHidden="true" />
        <!-- 1 -->
        <OutputField FieldID="CONSTITUENTID" Caption="Constituent ID" DataType="Guid" />
        <!-- 2 -->
        <OutputField FieldID="EMAILADDRESS" Caption="Email Address" DataType="String" />
        <!-- 3 -->
        <OutputField FieldID="EMAILADDRESSTYPE" Caption="Email Address Type" DataType="String" />
        <!-- 4 -->
        <OutputField FieldID="ISPRIMARY" Caption="Is Primary" DataType="Boolean" />
        <!-- 5 -->
        <OutputField FieldID="CHANGEDBYUSERNAME" Caption="Changed by User Name" DataType="String" />
      </OutputFields>
    </Output>
  </DataListSpec>
